#include "../include/Market.h"
#include "Poco/Util/IniFileConfiguration.h"
#include "Poco/DateTimeParser.h"
#include "../include/EventsConfiguration.h"
#include "../include/GeneralConfiguration.h"
#include <iostream>
#include <vector>
#include <string>
using namespace Poco;
using namespace Poco::Util;
using namespace std;

/**
 * Main method. Will not print Hello World to standard output
 * @return 0 = success.
 */
int main(int argc, char *argv[]) {

	Bank *bank = new Bank::Bank();
	CEventsConfiguration* conf;
	GeneralConfiguration* Gconf;
	EnergyMarketLogger::Instance().setLogLevel(5,6); //default values

	try {
		conf = new CEventsConfiguration(argv[2]);
	}
	catch (Exception e) {
		std::ostringstream strStream ;
		strStream << "events file not found.";
		EnergyMarketLogger::Instance().Log(strStream , Poco::Message::PRIO_CRITICAL);
		return 1;
	}


	try {
		cout<<"try"<<endl;
		Gconf = new GeneralConfiguration (argv[1]);
		cout<<"aftertry"<<endl;
	}
	catch (Exception e) {
		cout<<"catch"<<endl;
		std::ostringstream strStream ;
		strStream << "configuration file not found.";
		EnergyMarketLogger::Instance().Log(strStream , Poco::Message::PRIO_CRITICAL);
		delete conf;
		return 1;
	}
cout<<"gjddyygjy"<<endl;
	EnergyMarketLogger::Instance().setLogLevel(Gconf->getLoggerFP(),Gconf->getLoggerCP());
	Market market = Market(*bank, &(conf->getEvents()), Gconf->getAgentOn(), "config.ini", "Events.ini", 21911425, 36938173, vector<double>(7, Gconf->getEnergyValue()), Gconf->getAccount(),Gconf->getSayaBuying());

	market.startSim();

	delete conf;
	delete Gconf;
	delete bank;
}



